package com.doctcloud.hisinfo.histable.domain.insurance;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.NotZero;
import com.doctcloud.common.core.annotation.TableDesc;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

import static com.doctcloud.common.core.utils.StringUtils.trim;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"insuranceType","lowLevel"})
@TableDesc("门诊病人医疗保险支付方案")
public class PaySpecialExceptDictDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "医保类型")
    @NotBlank(message = "医保类型不得为空")
    private String insuranceType;
    @Excel(name = "计价类别")
    @NotBlank(message = "医保类型不得为空")
    private String itemClass;
    @Excel(name = "计价代码")
    @NotBlank(message = "医保类型不得为空")
    private String itemCode;
    @Excel(name = "计价规格")
    @NotBlank(message = "医保类型不得为空")
    private String itemSpec;
    @Excel(name = "个人支付比分子")
    @NotNull
    private Integer proportionNumerator;
    @Excel(name = "个人支付比分母")
    @NotZero(message = "个人支付比分母不得为空")
    private Integer proportionDenominator;
    /**
     * 由标准价格减去本限额确定此项目的个人支付部分。
     * 如果为空，个人支付部分费按上述比例计算；
     * 如果不为空，按实
     * 际免除额计算
     */
    @Excel(name = "补偿最高限额")
    private Double reimburseLimit;
    @Excel(name = "自费自负标志" , readConverterExp = "1=自负项目，2=非医保个人自费项目")
    private Double selfFlag;
    @Data
    public static class primaryKey {
        private final String insuranceType;
        private final Double lowLevel;
        public primaryKey(String insuranceType, Double lowLevel) {
            this.insuranceType = insuranceType;
            this.lowLevel = lowLevel;
        }
    }

    public void setInsuranceType(String insuranceType) {
        this.insuranceType = trim(insuranceType);
    }

    public void setItemCode(String itemCode) {
        this.itemCode = trim(itemCode);
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setProportionDenominator(Integer proportionDenominator) {
        this.proportionDenominator = proportionDenominator == null ? 1 : proportionDenominator;
    }
}
